﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Web;

namespace ArticleWeb
{
    public static class PageExtension
    {
        public static IQueryable<T> Query<T>(this IQueryable<T> query, int page, int size = RequestExtension.PageSize)
        {
            if (page <= 0)
                page = 1;
            return query.Skip((page - 1) * size).Take(size);
        }

        public static List<T> ToList<T>(this IQueryable<T> query, int page, int size = RequestExtension.PageSize)
        {
            if (page <= 0)
                page = 1;
            return query.Skip((page - 1) * size).Take(size).ToList();
        }
    }
}